package com.hznc.wcs.dto.wcs;

import com.diboot.core.binding.query.BindQuery;
import com.diboot.core.binding.query.Comparison;
import com.diboot.iam.entity.IamOrg;
import com.diboot.iam.entity.IamUser;
import com.hznc.wcs.entity.wcs.SystemLog;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

/**
* 日志管理 DTO定义
*
* @author MyName
* @version 1.0
* @date 2024-11-28
 * Copyright © MyCorp
*/
@Getter
@Setter
@Accessors(chain = true)
public class SystemLogDTO extends SystemLog  {
    private static final long serialVersionUID = 1952312484268839816L;

    /**
    * id集合
    */
    @BindQuery(comparison = Comparison.IN, field = "id")
    private List<String> ids;

    /**
    * 日期 起始
    */
    @BindQuery(comparison = Comparison.GE, field = "logDate")
    private LocalDate logDateBegin;

    /**
    * 日期 截止
    */
    @BindQuery(comparison = Comparison.LE, field = "logDate")
    private LocalDate logDateEnd;

    /**
    * 创建时间
    */
    @BindQuery(comparison = Comparison.GE)
    private LocalDateTime createTime;

    /**
    * 创建时间 起始
    */
    @BindQuery(comparison = Comparison.GE, field = "createTime")
    private LocalDate createTimeBegin;

    /**
    * 创建时间 截止
    */
    @BindQuery(comparison = Comparison.LT, field = "createTime")
    private LocalDate createTimeEnd;

    /**
    * 更新时间
    */
    @BindQuery(comparison = Comparison.GE)
    private LocalDateTime updateTime;

    /**
    * 更新时间 起始
    */
    @BindQuery(comparison = Comparison.GE, field = "updateTime")
    private LocalDate updateTimeBegin;

    /**
    * 更新时间 截止
    */
    @BindQuery(comparison = Comparison.LT, field = "updateTime")
    private LocalDate updateTimeEnd;

    public LocalDate getCreateTimeEnd() {
        if (getCreateTime() != null) {
            return getCreateTime().plusDays(1).toLocalDate();
        }
        if (createTimeEnd != null) {
            return createTimeEnd.plusDays(1);
        }
        return null;
    }

    public LocalDate getUpdateTimeEnd() {
        if (getUpdateTime() != null) {
            return getUpdateTime().plusDays(1).toLocalDate();
        }
        if (updateTimeEnd != null) {
            return updateTimeEnd.plusDays(1);
        }
        return null;
    }

}